<template>
  <div class="newsinfos">
    <h3>{{newsinfo.title}}</h3>
    <p class="infos">
      <span>发表时间:{{newsinfo.add_time | dataFormat}}</span>
      <span>点击次数:{{newsinfo.click}}</span>
    </p>
    <hr>
    <div v-html="newsinfo.content"></div>
    <comments :id="this.id"></comments>
  </div>
</template>
<script>
//引入评论组件
import comments from "./comments.vue";
import { Toast } from "mint-ui";
export default {
  data() {
    return {
      id: this.$route.params.id, //获取路由参数 挂载到data的id
      newsinfo: []
    };
  },
  created() {
    this.getnewsinfo();
  },
  methods: {
    getnewsinfo() {
      this.$http
        .get("http://www.liulongbin.top:3005/api/getnew/" + this.id)
        .then(result => {
          var result = result.body;
          if (result.status == 0) {
            this.newsinfo = result.message[0];
            // console.log(this.newsinfo);
          } else {
            Toast("加载失败");
          }
          //   console.log(result);ss
        });
    }
  },
  components: {
    comments
  }
};
</script>
<style scoped>
.newsinfos {
  padding: 5px;
}
h3 {
  color: red;
  text-align: center;
}
.infos {
  margin-top: 15px;
  display: flex;
  justify-content: space-between;
  color: blue;
}
</style>
